<?php

use console\db\channels\TransferTableMigration;

/**
 * 用户收藏内容转移
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m300000_000020_t_user_favorite extends TransferTableMigration {

    /**
     * @inheritdoc
     */
    public $sourceDb = 'olddb';

    /**
     * @inheritdoc
     */
    public function getTransferOptions() {
        return [
            'table' => [
                'user_favorite' => 'favorites',
            ],
            'columns' => [
                'user_id' => 'uid',
                'model' => 'model',
                'model_id' => 'modelid',
                'created_at' => function($data) {
                    if ($data['inputtime']) {
                        return $data['inputtime'];
                    }
                    return time();
                },
                'updated_at' => function($data) {
                    if ($data['inputtime']) {
                        return $data['inputtime'];
                    }
                    return time();
                },
            ],
        ];
    }

}
